<?php
	require_once("../conexion/conexion.php");
	require_once("../Funciones/funciones_publicas.php");
	$fun = new funciones_publicas();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>
<style>
.facNormal
{
	background:#D2B48C;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.facExenta
{
	background:#81D371;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.facElectronica
{
	background:#5F9EA0;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.cuadroNormal {
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 0px;
	padding: 0px;
	border: 1px solid #000000;
	background-color:#D2B48C;
	width:15px;
	height:15px;
}
.cuadroExenta {
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 0px;
	padding: 0px;
	border: 1px solid #000000;
	background-color:#81D371;
	width:15px;
	height:15px;
}
.cuadroElectronica {
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 0px;
	padding: 0px;
	border: 1px solid #000000;
	background-color:#5F9EA0;
	width:15px;
	height:15px;
}
#barras {
	padding: 0px;
	margin-top: 20px;
	margin-bottom:0px;
	margin-right:10px;
	margin-left:0px;
}

#barras  .cuadroNormal{
	padding-top: 0px;
	padding-left: 0px;
	margin: 0px;
	list-style-type: none;
	display: inline;/*deja alineado el menu horizontalmente*/
	padding-right: 20px;
}
#barras  .cuadroExenta{
	padding-top: 0px;
	padding-left: 0px;
	margin: 0px;
	list-style-type: none;
	display: inline;/*deja alineado el menu horizontalmente*/
	padding-right: 20px;
}
#barras  .cuadroElectronica{
	padding-top: 0px;
	padding-left: 0px;
	margin: 0px;
	list-style-type: none;
	display: inline;/*deja alineado el menu horizontalmente*/
	padding-right: 20px;
}
#barras  .excel{
	padding-top: 0px;
	padding-left: 0px;
	margin: 0px;
	list-style-type: none;
	display: inline;/*deja alineado el menu horizontalmente*/
	padding-right: 210px;
}
.filaSumatoria
{
	background:#CCCCCC;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
    font-size:12px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
</style>
<script>
$(document).ready(function() {
     $("#exportar").click(function(event) {
     //$("#datos_a_enviar").val( $("<div>").append( $("#tbExportar").eq(0).clone()).html());
	 $("#txtMes").val();
	 $("#txtAgno").val();
     $("#form_honorario").submit();
});
});

</script>
</head>

<body>
<form name="form_honorario" id="form_honorario" method="post" action="Reportes/Excel_Libro_Honorario.php">
<?php
$mes = $fun->SeleccionaMes($cmb_Mes);
//honorario
$con = new Conexion();
$con2 = $con->conexionBD("fpproduccion");
$sql = "select 
		date_format(HFecha,'%d/%m/%Y') as fecha,
		HNum,
		UsuNombre,
		honorario.UsuRut,
		HGlosa,
		HMonto
		
		from honorario
		inner join usuario on
		usuario.UsuRut=honorario.UsuRut
		where month(HFecha)='".$cmb_Mes."' and year(HFecha)='".$cmb_Agno."'
		order by HFecha asc";
$resultado = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
$fila = mysql_num_rows($resultado);
$con->cerrarBD();
if($fila >0)
{
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno" id="tbExportar">
<thead>
<tr>
	<td colspan="7"><input name="txtMes" id="txtMes" type="hidden" value="<?php echo $cmb_Mes;?>" /><input name="txtAgno" id="txtAgno" type="hidden" value="<?php echo $cmb_Agno;?>" /><input type="hidden" id="datos_a_enviar" name="datos_a_enviar" /><div class='option2'>
  <label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">Reporte Mes <?php echo $mes." ".$cmb_Agno?></label><div style="display:inline; margin-left:490px;"><img src="imagen/icono-excel.gif" width="20" height="20" title="Exportar a Excel" name="exportar" id="exportar" style="cursor: pointer; border: 1px solid green;" onmouseover="this.style.background='black';" onmouseout="this.style.background=''" /></div></td>
<td width="0%"></td>
</tr>
<tr>
	<th width="11%">fecha emision</th>
	<th width="9%">n&deg; boleta</th>
	<th width="24%">empleado</th>
	<th width="20%">glosa</th>
	<th width="10%">monto</th>
	<th width="14%">10% retenido</th>
	<th width="12%">total</th>
</tr>
</thead>
<?php
$sumatoria = 0;
$sumaMonto = 0;
$sumaRetenido = 0;
//honorario
while($reg = mysql_fetch_array($resultado))
{
	$retencion = ($reg['HMonto']*0.10);
	$total = ($reg['HMonto']-$retencion);
	echo "<tr>";
	echo "<td width=\"11%\" class='facExenta'>".$reg['fecha']."</td>";
	echo "<td width=\"9%\" class='facExenta'>".$reg['HNum']."</td>";
	echo "<td width=\"24%\" class='facExenta'>".$reg['UsuNombre']."</td>";
	echo "<td width=\"20%\" class='facExenta'>".$reg['HGlosa']."</td>";
	echo "<td width=\"10%\" class='facExenta'>".number_format ($reg['HMonto'],0,',','.')."</td>";
	echo "<td width=\"14%\" class='facExenta'>".number_format ($retencion,0,',','.')."</td>";
	echo "<td width=\"12%\" class='facExenta'>".number_format ($total,0,',','.')."</td>";
	echo "</tr>";
	$sumatoria += $total;
	$sumaMonto += $reg['HMonto'];
	$sumaRetenido += $retencion;
}
?>
<tr>
	<td colspan="4" class="filaSumatoria">TOTAL</td>
	<td class="filaSumatoria"><?php echo number_format ($sumaMonto,0,',','.')?></td>
	<td class="filaSumatoria"><?php echo number_format ($sumaRetenido,0,',','.')?></td>
	<td class="filaSumatoria"><?php echo number_format ($sumatoria,0,',','.')?></td>
</tr>
</table>
<?php 
}
else
{
    echo "<label style='font-size:16px; color:#CC3333; font-weight:bold;'>No Existen Resultados para la Busqueda</label>";
}
?>
<table>
<tr><td><div id="mensaje"></div></td></tr>
</table>
</form>
</body>
</html>
